#ifndef __CARD_TABLE
#define __CARD_TABLE

#include <math.h>
#include <stdio.h>
#include <pthread.h>

#include "lvgl/lvgl.h"
#include "lv_conf.h"
#include "../utils/log.h"
#include "game_room_list.h"
#include "../auth/game.h"
#include "../utils/axios.h"

extern pthread_mutex_t mutex;
extern const lv_img_dsc_t game_interface;
extern const lv_img_dsc_t Background;
extern const lv_img_dsc_t lord_tag;

extern const lv_img_dsc_t spade_A;
extern const lv_img_dsc_t spade_2;
extern const lv_img_dsc_t spade_3;
extern const lv_img_dsc_t spade_4;
extern const lv_img_dsc_t spade_5;
extern const lv_img_dsc_t spade_6;
extern const lv_img_dsc_t spade_7;
extern const lv_img_dsc_t spade_8;
extern const lv_img_dsc_t spade_9;
extern const lv_img_dsc_t spade_10;
extern const lv_img_dsc_t spade_J;
extern const lv_img_dsc_t spade_Q;
extern const lv_img_dsc_t spade_K;
extern const lv_img_dsc_t heart_A;
extern const lv_img_dsc_t heart_2;
extern const lv_img_dsc_t heart_3;
extern const lv_img_dsc_t heart_4;
extern const lv_img_dsc_t heart_5;
extern const lv_img_dsc_t heart_6;
extern const lv_img_dsc_t heart_7;
extern const lv_img_dsc_t heart_8;
extern const lv_img_dsc_t heart_9;
extern const lv_img_dsc_t heart_10;
extern const lv_img_dsc_t heart_J;
extern const lv_img_dsc_t heart_Q;
extern const lv_img_dsc_t heart_K;
extern const lv_img_dsc_t club_A;
extern const lv_img_dsc_t club_2;
extern const lv_img_dsc_t club_3;
extern const lv_img_dsc_t club_4;
extern const lv_img_dsc_t club_5;
extern const lv_img_dsc_t club_6;
extern const lv_img_dsc_t club_7;
extern const lv_img_dsc_t club_8;
extern const lv_img_dsc_t club_9;
extern const lv_img_dsc_t club_10;
extern const lv_img_dsc_t club_J;
extern const lv_img_dsc_t club_Q;
extern const lv_img_dsc_t club_K;
extern const lv_img_dsc_t diamond_A;
extern const lv_img_dsc_t diamond_2;
extern const lv_img_dsc_t diamond_3;
extern const lv_img_dsc_t diamond_4;
extern const lv_img_dsc_t diamond_5;
extern const lv_img_dsc_t diamond_6;
extern const lv_img_dsc_t diamond_7;
extern const lv_img_dsc_t diamond_8;
extern const lv_img_dsc_t diamond_9;
extern const lv_img_dsc_t diamond_10;
extern const lv_img_dsc_t diamond_J;
extern const lv_img_dsc_t diamond_Q;
extern const lv_img_dsc_t diamond_K;
extern const lv_img_dsc_t black_joker;
extern const lv_img_dsc_t red_joker;




#define CARD_NUMBER 54
#define CARD_CNT 13

#define LV_OBJ_FLAG_BUTTON_PRESSED LV_OBJ_FLAG_USER_1
#define ISHIDDEN LV_OBJ_FLAG_USER_2

// typedef enum {
//     SPADE,
//     HEART,
//     CLUB,
//     DIAMOND,
//     JOCKER,
// } CARD_SUIT;

// typedef enum {
//     CARD_SPADE_A,
//     CARD_SPADE_2,
//     CARD_SPADE_3,
//     CARD_SPADE_4,
//     CARD_SPADE_5,
//     CARD_SPADE_6,
//     CARD_SPADE_7,
//     CARD_SPADE_8,
//     CARD_SPADE_9,
//     CARD_SPADE_10,
//     CARD_SPADE_J,
//     CARD_SPADE_Q,
//     CARD_SPADE_K,
//     CARD_HEART_A,
//     CARD_HEART_2,
//     CARD_HEART_3,
//     CARD_HEART_4,
//     CARD_HEART_5,
//     CARD_HEART_6,
//     CARD_HEART_7,
//     CARD_HEART_8,
//     CARD_HEART_9,
//     CARD_HEART_10,
//     CARD_HEART_J,
//     CARD_HEART_Q,
//     CARD_HEART_K,
//     CARD_CLUB_A,
//     CARD_CLUB_2,
//     CARD_CLUB_3,
//     CARD_CLUB_4,
//     CARD_CLUB_5,
//     CARD_CLUB_6,
//     CARD_CLUB_7,
//     CARD_CLUB_8,
//     CARD_CLUB_9,
//     CARD_CLUB_10,
//     CARD_CLUB_J,
//     CARD_CLUB_Q,
//     CARD_CLUB_K,
//     CARD_DIAMOND_A,
//     CARD_DIAMOND_2,
//     CARD_DIAMOND_3,
//     CARD_DIAMOND_4,
//     CARD_DIAMOND_5,
//     CARD_DIAMOND_6,
//     CARD_DIAMOND_7,
//     CARD_DIAMOND_8,
//     CARD_DIAMOND_9,
//     CARD_DIAMOND_10,
//     CARD_DIAMOND_J,
//     CARD_DIAMOND_Q,
//     CARD_DIAMOND_K,
//     CARD_BLACK_JOCKER,
//     CARD_RED_JOCKER,
// } CARD;

#define CARD_FLOWER(card) (CARD_SUIT)((card) / CARD_CNT)

#define CARD_VALUE(card) ((card) % CARD_CNT)

#define CARD_IS_JOCKER(card) ((card) == CARD_BLACK_JOCKER || (card) == CARD_RED_JOCKER)

extern const lv_img_dsc_t *cards[54];

void table_page_display();
void table_page_destroy();

#endif